package cn.cs.service;

import cn.cs.mapper.CsPartsMapper;
import cn.cs.pojo.CsParts;
import cn.cs.pojo.CsPartsAttribute;
import cn.cs.pojo.CsPartsQrCode;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class CsPartsService {

    @Resource
    private CsPartsMapper partsMapper;

    @RequestMapping(value = "/getCsPartsById", method = RequestMethod.POST)
    public CsParts getCsPartsById(@RequestParam("id") String id) throws Exception{
        return partsMapper.getCsPartsById(id);
    }

    @RequestMapping(value = "/getCsPartsByName", method = RequestMethod.POST)
    public CsParts getCsPartsByName(@RequestParam("parts_name") String parts_name) throws Exception{
        return partsMapper.getCsPartsByName(parts_name);
    }

    @RequestMapping(value = "/getCsPartsByFactoryId", method = RequestMethod.POST)
    public List<CsParts> getCsPartsByFactoryId(@RequestParam("factory_id") String factory_id, @RequestParam("factory_name") String factory_name, @RequestParam("parts_name") String parts_name) throws Exception{
        return partsMapper.getCsPartsByFactoryId(factory_id, factory_name, parts_name);
    }

    @RequestMapping(value = "/getCsPartsListByMap", method = RequestMethod.POST)
    public List<CsParts> getCsPartsListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return partsMapper.getCsPartsListByMap(param);
    }

    @RequestMapping(value = "/getCsPartsCountByMap", method = RequestMethod.POST)
    public Integer getCsPartsCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return partsMapper.getCsPartsCountByMap(param);
    }

    @RequestMapping(value = "/insertCsParts", method = RequestMethod.POST)
    public Integer insertCsParts(@RequestBody CsParts csParts) throws Exception{
        return partsMapper.insertCsParts(csParts);
    }

    @RequestMapping(value = "/addPartsAttribute", method = RequestMethod.POST)
    public Integer addPartsAttribute(@RequestBody CsPartsAttribute partsAttribute) throws Exception{
        return partsMapper.addPartsAttribute(partsAttribute);
    }

    @RequestMapping(value = "/updateCsParts", method = RequestMethod.POST)
    public Integer updateCsParts(@RequestBody CsParts csParts) throws Exception{
        return partsMapper.updateCsParts(csParts);
    }

    @RequestMapping(value = "/updatePartsAttribute", method = RequestMethod.POST)
    public Integer updatePartsAttribute(@RequestBody CsPartsAttribute partsAttribute) throws Exception{
        return partsMapper.updatePartsAttribute(partsAttribute);
    }

    @RequestMapping(value = "/deleteCsPartsById", method = RequestMethod.POST)
    public Integer deleteCsPartsById(@RequestParam("id") String id) throws Exception{
        return partsMapper.deleteCsPartsById(id);
    }

    @RequestMapping(value = "/deleteCsPartsImgByPartsId", method = RequestMethod.POST)
    public Integer deleteCsPartsImgByPartsId(@RequestParam("partsId") String partsId) throws Exception{
        return partsMapper.deleteCsPartsImgByPartsId(partsId);
    }

    @RequestMapping(value = "/deletePartsAttribute", method = RequestMethod.POST)
    public Integer deletePartsAttribute(@RequestParam("id") String id) throws Exception{
        return partsMapper.deletePartsAttribute(id);
    }

    @RequestMapping(value = "/insertCsPartsImgList", method = RequestMethod.POST)
    public Integer insertCsPartsImgList(@RequestBody List<Map<String, Object>> list)throws Exception{
        return partsMapper.insertCsPartsImgList(list);
    }

    @RequestMapping(value = "/insertCsPartsQRcodeList", method = RequestMethod.POST)
    public Integer insertCsPartsQRcodeList(@RequestBody List<Map<String, Object>> list)throws Exception{
        return partsMapper.insertCsPartsQRcodeList(list);
    }

    @RequestMapping(value = "/updateCsPartsQRcode", method = RequestMethod.POST)
    public Integer updateCsPartsQRcode(@RequestBody Map<String, Object> map)throws Exception{
        return partsMapper.updateCsPartsQRcode(map);
    }

    @RequestMapping(value = "/getCsPartsQRcodeListByMap", method = RequestMethod.POST)
    public List<Map<String, Object>> getCsPartsQRcodeListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return partsMapper.getCsPartsQRcodeListByMap(param);
    }

    @RequestMapping(value = "/getCsPartsQRcodeCountByMap", method = RequestMethod.POST)
    public Integer getCsPartsQRcodeCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return partsMapper.getCsPartsQRcodeCountByMap(param);
    }

    @RequestMapping(value = "/getHistoryByQRcode", method = RequestMethod.POST)
    public List<Map<String, Object>> getHistoryByQRcode(@RequestBody String QRcode) throws Exception{
        return partsMapper.getHistoryByQRcode(QRcode);
    }

    @RequestMapping(value = "/getPartsByQRcode", method = RequestMethod.POST)
    public Map<String, Object> getPartsByQRcode(@RequestBody String QRcode) throws Exception{
        return partsMapper.getPartsByQRcode(QRcode);
    }

    @RequestMapping(value = "/getPartsSellNum", method = RequestMethod.POST)
    public List<Map<String, Object>> getPartsSellNum(@RequestBody Map<String, Object> param) throws Exception{
        return partsMapper.getPartsSellNum(param);
    }

    @RequestMapping(value = "/getPartsSellNumCount", method = RequestMethod.POST)
    public Integer getPartsSellNumCount(@RequestBody Map<String, Object> param) throws Exception{
        return partsMapper.getPartsSellNumCount(param);
    }

    @RequestMapping(value = "/getQrcodeMax", method = RequestMethod.POST)
    public Long getQrcodeMax(@RequestParam("partsId") String partsId) throws Exception{
        return partsMapper.getQrcodeMax(partsId);
    }

    @RequestMapping(value = "/getPartsQrcodeList", method = RequestMethod.POST)
    public List<Map<String, Object>>  getPartsQrcodeList(@RequestParam("partsId") String partsId, @RequestParam("startCode") String startCode, @RequestParam("endCode") String endCode) throws Exception{
        return partsMapper.getPartsQrcodeList(partsId, startCode, endCode);
    }

    @RequestMapping(value = "/getPartsQrcodeListEntity", method = RequestMethod.POST)
    public List<CsPartsQrCode>  getPartsQrcodeListEntity(@RequestParam("partsId") String partsId, @RequestParam("startCode") String startCode, @RequestParam("endCode") String endCode) throws Exception{
        return partsMapper.getPartsQrcodeListEntity(partsId, startCode, endCode);
    }

    
}
